package com.yan.Demo;

public class ExpectionDemo2 {

    public static void main1(String[] args) throws MyException {
        try {
            throw  new MyException("×");
        } catch (MyException e) {
            System.out.println("√");
        }
    }



    public static void main2(String[] args) {
        int a = 17;
        if(a < 18){
            try {
                throw new MyRuntimeException("×");
            } catch (Exception e) {
                a = 19;
                System.out.println("√");
            }
        }
    }

}

class MyRuntimeException extends RuntimeException{
    public MyRuntimeException() {
    }

    public MyRuntimeException(String message) {
        super(message);
    }
}

class MyException extends Exception{
    public MyException() {

    }

    public MyException(String message) {
        super(message);
    }
}
